﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sunlit.House.Floors;
using Sunlit.House.Floors.Dto;
using Sunlit.House.Seconds;
using Sunlit.House.Seconds.Dto;
using Sunlit.House.Buy;
using Sunlit.House.Buy.Dto;

namespace Sunlit.House
{
    internal class CustomDtoMapper
    {
        public static void CreateMappings(IMapperConfigurationExpression cfg)
        {
            cfg.CreateMap<Floor, FloorDto>()
                .ForMember(r => r.CoverImageUrl, opt => opt.MapFrom(l => l.FloorImages.FirstOrDefault().ImageUrl));

            cfg.CreateMap<SecondHand, SecondHandDto>()
                .ForMember(r => r.CoverImageUrl, opt => opt.MapFrom(l => l.SecondHandImages.FirstOrDefault().ImageUrl));

            cfg.CreateMap<GroupItem, GroupItemDto>()
                .ForMember(r => r.GroupBuyTypeId, opt => opt.MapFrom(l => l.GroupBuy.GroupBuyTypeId));
        }
    }
}
